declare
Rules=
r(sexpr:[fun {$} As in
            rule(sexpr(s(As)) [t('(') seq(As) t(')')])
         end]
  seq:  [fun {$}
            rule(seq(nil) nil)
         end
         fun {$} As A in
            rule(seq(A|As) [atom(A) seq(As)])
         end
         fun {$} As A in
            rule(seq(A|As) [sexpr(A) seq(As)])
         end]
  atom: [fun {$} X in
            rule(atom(X)
                 [t(X)
                  fun {$}
                     {IsAtom X} andthen X\='(' andthen X\=')'
                  end])
         end])

